package com.miaoji.controller;

import com.miaoji.domain.dto.PageInfo;
import com.miaoji.domain.po.OrderInfo;
import com.miaoji.domain.vo.OrderVo;
import com.miaoji.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/order")
public class OrderCenterController {
    @Autowired
    OrderService orderService;

    @GetMapping("/init")
    public Map<PageInfo, List<OrderVo>> orderInit() {
        return orderService.OrderSelectAll(1,null);
    }

    @GetMapping("/selectPage")
    public Map<PageInfo, List<OrderVo>> orderSelect(int number) {
        return orderService.OrderSelectAll(number,null);
    }

    @GetMapping("/selectQuery")
    public Map<PageInfo, List<OrderVo>> orderSelect(int number,OrderInfo orderInfo) {
         return orderService.OrderSelectAll(number,orderInfo);
    }


    @PostMapping("/updateState")
    public boolean orderUpdateState(@RequestBody OrderInfo orderInfo) {
        return orderService.OrderUpdateState(orderInfo);
    }

    @PostMapping("/updateLogistics")
    public boolean orderUpdateLogistics(@RequestBody OrderInfo orderInfo) {
        return orderService.OrderDeliverDetail(orderInfo);
    }

    @PostMapping("/deleteOrder")
    public boolean orderDelete(@RequestBody OrderInfo orderInfo) {
        return orderService.OrderDelete(orderInfo);
    }

    @PostMapping("/orderRefund")
    public boolean orderRefund(@RequestBody OrderInfo orderInfo){
        return orderService.OrderRefund(orderInfo.getOrderId());
    }
}
